package com.zan.pattern.mediator;

/**
 * @Author Zan
 * @Create 2024/4/27 16:08
 * @Description : 具体中介角色类
 * @ClassName: MediatorStructure
 */
public class MediatorStructure extends Mediator {

    // 聚合房东和租房者对象
    private HouseOwner houseOwner;

    private Tenant tenant;

    public HouseOwner getHouseOwner() {
        return houseOwner;
    }

    public void setHouseOwner(HouseOwner houseOwner) {
        this.houseOwner = houseOwner;
    }

    public Tenant getTenant() {
        return tenant;
    }

    public void setTenant(Tenant tenant) {
        this.tenant = tenant;
    }

    @Override
    public void constact(String message, Person person) {
        if (person == houseOwner) {
            tenant.getMessage(message);
        } else if (person == tenant) {
            houseOwner.getMessage(message);
        }
    }
}
